﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class UCLogin : System.Web.UI.UserControl
{
    private UserInfo user = new UserInfo();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
        }
    }
    protected void btn_SignIn_Click(object sender, EventArgs e)
    {
        user.StrUserName = this.txtUserName.Text;
        user.StrPassWord = this.txtPassword.Text;

        ProLogin plLogin = new ProLogin();
        user = plLogin.CheckLogin(user);

        if (user == null)
        {
            Response.Redirect("login.aspx?err=true");
        }
        else
        {
            //Session["user"] = this.txtUserName.Text;
            
            Session.Timeout = 500000;
            Session.Add("user", this.txtUserName.Text);
            Session.Add("userinfo", user);
            //HttpCookie cookie = new HttpCookie("LoginForm");
            //cookie.Values.Add("Username", "username");
            //cookie.Expires = DateTime.Now.AddDays(14);
            //HttpContext.Current.Response.Cookies.Add(cookie);
            Response.Redirect("default.aspx?uid=" + this.txtUserName.Text);
        }
    }
    protected void btn_ForgotPassword_Click(object sender, EventArgs e)
    {
        Response.Redirect("ForgotPass.aspx");
    }
    protected void Register_Click(object sender, EventArgs e)
    {
        Response.Redirect("Register.aspx");
    }
}
